#include "MineDesign3D/Render/BlockRenderer.hpp"
#include "MineDesign3D/ArchiveManager.hpp"
#include "MineDesign3D/DBManager.hpp"

#include <Windows.h>
#include <GL/GL.h>
#include "MineDesign3D/Render/RenderNormalBlock.hpp"
#include "MineDesign3D/Render/RenderSpecialBlock.hpp"
namespace MineDesign3D{
namespace Render{
BlockRenderer::BlockRenderer()
{
	Archive::IFile::ptr pFile = g_pArchiveManager()->load("BlockTexture.png");
	m_Texture = GLHelper::ITexture::Create(pFile->data(),pFile->size());
}
void BlockRenderer::Begin()const
{
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.05f);

	m_Texture->Bind();
}
void BlockRenderer::End()const
{
	m_Texture->UnBind();
	glDisable(GL_ALPHA_TEST);
}
void BlockRenderer::Render(int BlockID)const
{
	if(g_pDBManager()->isNormalBlock(BlockID))
	{
		Render::RenderNormalBlock(BlockID);
	}
	else
	{
		Render::RenderSpecialBlock(BlockID);
	}
}
}//Render
}//MineDesign3D